//import com.sun.tools.internal.ws.processor.util.DirectoryUtil;

import java.io.InputStream;
import java.util.*;

import com.jeeplus.common.utils.MyBeanUtils;
import com.jeeplus.common.utils.XmlUtils;
import com.jeeplus.core.mapper.JsonMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.sys.entity.Api;
import com.jeeplus.modules.tools.utils.MultiDBUtils;

import static com.alibaba.fastjson.JSON.parse;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.builder.BaseBuilder;
import org.apache.ibatis.builder.BuilderException;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.executor.ErrorContext;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.parsing.XNode;
import org.apache.ibatis.parsing.XPathParser;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.poi.ss.formula.functions.T;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.junit.Test;
import org.w3c.dom.Node;

/**
 * @author Administrator
 * @title: demo
 * @projectName jeeplus
 * @description: TODO
 * @date 2019/7/1715:05
 */
public class demo   {


    @Test
    public void test() throws Exception {

        String filePath="d:/areaMapper.xml";
        for (Element element: XmlUtils.getListNodes(filePath,"//update")){

            if(element.attribute("id").getValue().equals("updateAreas")){
                for (int i=0;i<element.nodeCount();i++){
                    if(element.node(i).getPath().contains("include")){
                        for (Element e:XmlUtils.getChildList(element)){
                            String ele=e.attribute("refid").getValue();
                            for (Element e1:XmlUtils.getListNodes(filePath,"//sql")){
                                if(e1.attribute("id").getValue().equals(ele)){
                                    System.out.println(e1.getTextTrim());
                                }
                            }
                        }
                    }
                    else {

                        System.out.println(element.node(i).getStringValue());
                    }
                }
            }
        }

    }


}
